import React from 'react';
import { connect } from 'dva'
import { Button, List, WhiteSpace, TextareaItem ,InputItem } from 'antd-mobile';
import banner from '../../../../assets/work/dsb.jpg';
import banner4 from '../../../../assets/work/banner6.jpg';
import styles from './history.less';
import { routerRedux } from 'dva/router';
const Item = List.Item;
const Brief = Item.Brief;
class applyhistory extends React.Component {

  constructor(props) {
    super(props);
    this.state = {}
    {/* if (this.props.location.query.code) {
      this.props.dispatch({
        type: 'dangyuanlists/fetch',//this.props.location.query.code
        payload: {code: this.props.location.query.code, relation: ["extend"]},
      });
    }*/
    }
  }

  itemClick = (id) => {
    this.props.dispatch(
      routerRedux.push({
        pathname: "/work/zzgx/transferdetails",
        query: {id: id},
      })
    )
  }

  render() {
    const Lists = [];
    const Data = this.props.list;
    for (let key in Data) {
      Lists.push(Data[key])
    }
    let newsObject = sessionStorage.getItem('userdata');
    newsObject = JSON.parse(newsObject);
    if(!newsObject){
      this.props.dispatch(
        routerRedux.push({
          pathname: "/login",
        })
      )
    }
    return (
      <div className="history">
        <List className="name-list">
          <Item align="top" thumb={newsObject[0].administrator[4].avatar ? newsObject[0].administrator[4].avatar : banner4}
                multipleLine>{newsObject[0].administrator[1].username}<Brief>{newsObject[0].administrator[2].realname}</Brief>
          </Item>
        </List>
        <WhiteSpace size="lg"/>
        {this.props.list &&
        Lists.map((it) => {
          return <List className="lists">
            {/*onClick={this.itemClick(it.id)}*/}
            <Item
              onClick={() => this.itemClick(it.id)}
              style={{width: '90%', display: 'inline-block'}} extra={<div
              style={{
                width: '1.5rem',
                transform: 'rotate(-45deg)',
                height: '1rem',
                textAlign: 'center',
                marginLeft: '1.5rem',
                fontSize: '0.4rem'
              }}><span style={{fontSize: '0.3rem', color: '#55A0FE'}}>{it.status_text}</span></div>}>
              <span>由</span>&nbsp;&nbsp;
              <span style={{fontSize: '0.3rem', color: '#666'}}>{it.origin_org_name}</span>
              <Brief><span style={{color: '#55A0FE'}}>转至</span>&nbsp;&nbsp;<span
                style={{fontSize: '0.3rem', color: '#333'}}></span>{it.goal_org_name}</Brief>
            </Item>
          </List>
        })
        }
      </div>
    )
  }
}
function mapStateToProps({PartyOfintegra,historys}) {
  return {
    list: historys.Lists
  }
}
export default connect(mapStateToProps)(applyhistory);

